/**
 * @(#) reqMedicalSubtractionMediator.as
 *
 * @date		2009. 04. 20.
 * @version		1.0
 * @author		Jo, ChangHun
 * @description	연말정산 메인 view - Mediator
 * 				연말정산 - 탭6 의료비 공제 Logic을 관리 
 */
package com.skt.common_hr.yearadjustment.view
{
	import com.skt.common_hr.common.puremvc.CommonMediator;
	import com.skt.common_hr.yearadjustment.view.components.popMedicalSubtraction;
	import com.skt.common_hr.yearadjustment.view.components.reqMedicalSubtraction;
	
	import flash.display.Sprite;
	import flash.events.Event;
	
	import mx.core.Application;
	import mx.core.IFlexDisplayObject;
	import mx.managers.PopUpManager;
	
	import org.puremvc.as3.multicore.interfaces.INotification;
	
	public class reqMedicalSubtractionMediator extends CommonMediator
	{
		public static const NAME:String = "reqMedicalSubtractionMediator";
		
		/**
		 * 생성자
		 * 
		 * @param
		 * @return void
		 * */
		public function reqMedicalSubtractionMediator( viewComponent:Object ):void
		{
			super(NAME, viewComponent);
			view.callLater(initView);
		}
		
		/**
		 * View를 초기화 한다.
		 * 	- View에 기본사항을 출력하고 data를 load
		 * @param
		 * @return void
		 * */
		public function initView():void
		{
			view.addEventListener(reqMedicalSubtraction.MEDICAL_EDIT_OPEN, onMedicalEditOpen);
		}
		
		private function onMedicalEditOpen(event:Event):void
		{
			var center:Sprite = Sprite(mx.core.Application.application);
			var popMediator:popMedicalSubtractionMediator = facade.retrieveMediator(popMedicalSubtractionMediator.NAME) as popMedicalSubtractionMediator;
			var popView:IFlexDisplayObject = PopUpManager.createPopUp(center, popMedicalSubtraction, true);
			
			PopUpManager.centerPopUp(popView);
			popView.y-=50;
			//(popView as popMedicalSubtraction).MedicalSubtractionVO = view._medicalVo;
			/* if(!popMediator) {
				facade.removeMediator(popMedicalSubtractionMediator.NAME);
			} */
			
			popMediator = new popMedicalSubtractionMediator(popView);
			facade.registerMediator(popMediator);
			popMediator.v_year = view._selYear;
			popMediator.v_enable = view._isEnable;
			if(view._medicalVo!=null) {
				popMediator.v_3percent = view._medicalVo.PCNT3;
			}
			else {
				popMediator.v_3percent = 0;
			}
		}
		
		
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Process MVC Messages
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
		
		/**
		 * 본 Class에서 처리해야할 Noti들을 등록한다.
		 * 
		 * @param
		 * @return void
		 * */
		override public function listNotificationInterests():Array
		{
			return [
					
					];
		}
		
		
		/**
		 * Noti별로 처리한다.
		 * 
		 * @param
		 * @return void
		 * */
		override public function handleNotification(note:INotification):void
		{
			switch (note.getName())
			{
				default:
					//trace(this.instanceID+"에서 처리 안된 Noti가 검출됨 : " + note.getBody());
					break;
			}
		}
		
		
		
		
		
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Utility Functions
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
		
		private function get view():reqMedicalSubtraction
		{
			return viewComponent as reqMedicalSubtraction;
		}
	}
}